package srms.the505div1;

public class RectangleArea {
	public int minimumQueries(String[] known) {
		boolean[][] asked;
		int result = 0;

		int n = known.length;
		int m = known[0].length();
		asked = new boolean[n][m];

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				asked[i][j] = 'Y' == known[i].charAt(j);
			}
		}

		for (int k = 0; k < 2; k++) {
			for (int y = 0; y < n; y++) {
				next: for (int x = 0; x < m; x++) {
					if (!asked[y][x]) {
						for (int yy = 0; yy < n; yy++) {
							for (int xx = 0; xx < m; xx++) {
								if (asked[yy][xx] && asked[y][xx] && asked[yy][x]) { //every row or column has more than 2 Y
									asked[y][x] = true;
									continue next;
								}
							}
						}
						if (k > 0 && !asked[y][x]) {
							result++;
							asked[y][x] = true;
						}
					}
				}
			}
		}

		return result;
	}
}
